package xuanke;
import java.util.Arrays;
public class Student extends Person{
    Student(String a,String b,String c,Course[] d){
    	super(a,b,c,d);
        number=a;
        name=b;
        sex=c;
        course=d;
    }
    //退课：数组的缩容以删除元素
    void tuike(Course c){
        for(int i=0;i<this.course.length;i++){
        	
            if(c.name== course[i].name){//当前要退的课程的名称和数组中第i个元素的一样
                for(int j=1;j<this.course.length-i;j++){
                    course[i+j-1]=course[i+j];//被删除元素后面的元素往前移动一位
                }
                
                course = Arrays.copyOf(course,course.length-1);//缩容
            }
        }
    }
    public String toString(){
    	var x="学生姓名:"+this.name+"\n学生编号:"+this.number+
        "\n学生性别:"+this.sex;
    	

    	for(int i = 0; i<this.course.length; i++){
    	    System.out.println("课程编号:"+this.course[i].number+"\t课程名称:"+this.course[i].name+"\t上课时间:"
    	            +this.course[i].time+"\t上课地点:"+this.course[i].place+"\t教师:"+this.course[i].teacher.name+" \t教师编号："+this.course[i].teacher.number);
    	}
    	return x;
    	

    	}
    	
    
}


	
	

  